﻿@{
    Layout = "~/Views/Shared/_ch.cshtml";
}
<link href="~/Styles/gundong.css" rel="stylesheet" />
<link href="~/Styles/MainCss.css" rel="stylesheet" />
<style type="text/css">
    .jumbotron {
        padding-top: 0;
        padding-bottom: 0;
        background-color: none;
    }

    #rightlist img {
        width: 40%;
        margin: 5%;
    }
</style>
<div class="bodymain">
    <div class="bodytitle">
        <a href="#" class="pull-left"><img src="@Url.Content(MinHangWisdomParkWeb.GlobalParameter.LogoUrl)" /></a>
        <div class="bodytitletab pull-left">
            <a href="Main">首页</a>
            <a href="TypeContent?TypeName=新闻">新闻</a>
            <a href="TypeContent?TypeName=公告">公告</a>
            <a href="TypeContent?TypeName=政策">政策</a>
            <a href="TypeContent?TypeName=企业">企业</a>
            <a href="http://www.anjismart.com/m/Jokul/">网络社区</a>
        </div>
    </div>
    <div class="bodycontent">
        <div class="row">
            <div class="col-lg-12">
                <ol class="breadcrumb">
                    <li><a href="Main">首页</a></li>
                    <li class="active">@ViewBag.Title</li>
                </ol>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-8">
                @*左边内容*@
                <input type="hidden" value="@ViewBag.Title" id="TypeName" />
                <input type="hidden" value="@ViewBag.Count" id="count" />
                <div class="list-group" id="content">

                </div>
                <nav class="text-center">
                    @*分页*@
                    <ul class="pagination">
                        <li>
                            <a href="#" aria-label="Previous" class="listshang">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>

                        <li>
                            <a href="#" aria-label="Next" class="listxia">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
            <div class="col-lg-4" id="rightlist">
                @*右边列表*@


            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var number = 10;
    var count = Math.ceil($('#count').val() / 10);
    //var count = 12;
    $(function () {
        var typename = $('#TypeName').val();
        contentlist(typename, 1);
        counts();
        AllPeblish(typename);
    })

    function counts() {
        var str = '';
        if (count > 1) {
            for (var i = 1; i <= 5; i++) {
                if (i == 1) {
                    str += '<li class="active num"><a href="#">' + i + '</a></li>';
                } else if (i <= count) {
                    str += '<li class="num"><a href="#">' + i + '</a></li>';
                }
            }
            $('.listshang').parent().after(str);
        } else {
            $('.text-center').empty();
        }
    }



    $(".listshang").click(function () {
        var num = $(".pagination").find(".active");
        var typename = $('#TypeName').val();
        if (num.text() != '1') {
            if (num.prev().find("span").text() != "«") {
                num.removeClass("active");
                num.prev().addClass("active");
                contentlist(typename, num.prev().text());
            } else if (num.prev().find("span").text() == "«") {
                num.parent().find('.num').remove();
                var i = 5;
                var str = '';
                for (var i; i >= 1; i--) {
                    if (i == 1) {
                        str += '<li class="active num"><a href="#">' + (Number(num.text()) - i) + '</a></li>';
                        contentlist(typename, (Number(num) - i));
                    } else {
                        str += '<li class="num"><a href="#">' + (Number(num.text()) - i) + '</a></li>'
                    }
                }
                $('.listshang').parent().after(str);
            }
        }
    })

    $(".listxia").click(function () {
        var num = $(".pagination").find(".active");
        if (num.text() != count) {
            if (num.next().find("span").text() != "»") {
                num.removeClass("active");
                num.next().addClass("active");
                var typename = $('#TypeName').val();
                contentlist(typename, num.next().text());
            } else if (num.next().find('span').text() == "»") {
                num.parent().find('.num').remove();
                var i = 1;
                var str = '';
                for (var i; i <= 5; i++) {
                    if (i == 1) {
                        str += '<li class="active num"><a href="#">' + (Number(num.text()) + i) + '</a></li>';
                        contentlist(typename, (Number(num) + i));
                    } else if ((Number(num.text()) + i) <= count) {
                        str += '<li class="num"><a href="#">' + (Number(num.text()) + i) + '</a></li>'
                    }
                }
                $('.listshang').parent().after(str);
            }
        }
    })



    $(document).on('click', '.num', function () {
        $(this).siblings().removeClass('active');
        $(this).addClass('active');
        var typename = $('#TypeName').val();
        contentlist(typename, $(this).text());
    })

    function contentlist(typename, pageindex) {
        $("#content").empty();
        $.post("TypeLie", { typename: typename, pageindex: pageindex }, function (data, status) {
            if (status == "success") {
                var str = "";
                $.each(data, function (i, item) {
                    if (item != null && item.PeblishContent.length > 30) {
                        peblishcontent = item.PeblishContent.substring(0, 30) + '...';
                    } else {
                        peblishcontent = item.PeblishContent;
                    }
                    str += ' <a href="TextContent?TypeName=' + typename + '&PeblishID=' + item.PeblishID + '" class="list-group-item ">'
                    + '<h4 class="list-group-item-heading"><b>' + item.PeblishTitle + '</b></h4>'
                    + '<p class="list-group-item-text">' + peblishcontent + '</p></a>';
                })
                $("#content").append(str);
            }
        })
    }





    //右边列表
    function AllPeblish(typename) {
        $.post("AllPeblish", function (data, status) {
            if (status == "success") {
                var str = '';
                if (typename != "新闻") {
                    str += '<div class="panel panel-default">' +
                    '<div class="panel-heading">新闻</div>' +
                    '<ul class="list-group">';
                    $.each(data.News, function (i, item) {
                        str += '<li class="list-group-item"><a href="TextContent?TypeName=新闻&PeblishID=' + item.PeblishID + '">' + item.PeblishTitle + '</a></li>'
                    })
                    str += '</ul></div>';
                }
                if (typename != "公告") {
                    str += '<div class="panel panel-default">' +
                    '<div class="panel-heading">公告</div>' +
                    '<ul class="list-group">';
                    $.each(data.Notice, function (i, item) {
                        str += '<li class="list-group-item"><a href="TextContent?TypeName=公公啊&PeblishID=' + item.PeblishID + '">' + item.PeblishTitle + '</a></li>'
                    })
                    str += '</ul></div>';
                }
                if (typename != "政策") {
                    str += '<div class="panel panel-default">' +
                    '<div class="panel-heading">政策</div>' +
                    '<ul class="list-group">';
                    $.each(data.Policy, function (i, item) {
                        str += '<li class="list-group-item"><a href="TextContent?TypeName=政策&PeblishID=' + item.PeblishID + '">' + item.PeblishTitle + '</a></li>'
                    })
                    str += '</ul></div>';
                }
                if (typename != "企业") {
                    str += '<div class="panel panel-default">' +
                    '<div class="panel-heading">企业</div>' +
                    '<ul class="list-group">';
                    $.each(data.Enterprises, function (i, item) {
                        str += '<li class="list-group-item"><a href="TextContent?TypeName=企业&PeblishID=' + item.PeblishID + '">' + item.PeblishTitle + '</a></li>'
                    })
                    str += '</ul></div>';
                }
                if (typename != "广告") {
                    str += '<div class="panel panel-default">' +
                   '<div class="panel-heading">广告</div>';
                    $.each(data.Advert, function (i, item) {
                        str += '<a  href="' + item.httpurl + '"><img src="../' + item.imgurl + '" alt="..." class="img-thumbnail"></a>';
                    })
                    str += '</div>';
                }
                $('#rightlist').append(str);
            }
        })
    }





</script>